#include <iostream>
#define MAXN 200005
using namespace std;
int T, N, M;
int par[MAXN];

int find(int x) {
    if (par[x] == x) return x;
    return par[x] = find(par[x]);
}

void unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return;
    par[x] = y;
}

bool same(int x, int y) {
    return find(x) == find(y);
}

void solve();
int main() {
    ios::sync_with_stdio(false);
    cin >> T;
    while (T--) {
        cin >> N >> M;
        solve();
    }
}

void solve() {
    for (int i = 1; i <= 2 * N; i++) par[i] = i;
    char type; int x, y;
    while (M--) {
        cin >> type >> x >> y;
        if (type == 'D') {
            unite(x, y + N); unite(x + N, y);
        } else {
            // 查询关系
            if (same(x, y + N) || same(x + N, y)) cout << "In different gangs." << endl;
            else if (same(x, y) || same(x + N, y + N)) cout << "In the same gang." << endl;
            else cout << "Not sure yet." << endl;
        }
    }
    return;
}